package org.readium.r2.testapp.data

import org.readium.r2.testapp.data.db.DictionaryDao
import org.readium.r2.testapp.data.model.Vocabulary

class VocabularyRepository(
    private val dictionaryDao: DictionaryDao
) {

    var lookupWord: Long = 0

    var addedWord: Long = 0

    var addedSentence: Long = 0

    suspend fun get(entry: String) =
        dictionaryDao.get(entry)

    fun searchVocabulary(entry: String) =
        dictionaryDao.searchVocabulary(entry)

    suspend fun markVocabulary(entry: String, isMarked: Boolean) =
        dictionaryDao.markVocabulary(entry, isMarked)

    fun getAllVocabularyMarked() =
        dictionaryDao.getAllVocabularyMarked()

    suspend fun insertVocabulary(
        entry: String,
        definition: String,
        isMarked: Boolean = true
    ) {
        val vocabulary = Vocabulary(
            entry = entry,
            definition = definition,
            isMarked = isMarked
        )
        dictionaryDao.insertVocabulary(vocabulary)
    }

    suspend fun deleteVocabulary(entry: String) =
        dictionaryDao.deleteVocabulary(entry)
}
